package model

type Response struct {
	ResultCode int         `json:"resultCode"`
	ResultDesc string      `json:"resultDesc"`
	Data       interface{} `json:"data"`
}

func SuccessResponse(data interface{}) *Response {
	return &Response{
		ResultCode: 0,
		ResultDesc: "success",
		Data:       data,
	}
}

func FailResponse(err error) *Response {
	return &Response{
		ResultCode: 500,
		ResultDesc: err.Error(),
		Data:       nil,
	}
}

func FailResponseDesc(desc string) *Response {
	return &Response{
		ResultCode: 500,
		ResultDesc: desc,
		Data:       nil,
	}
}

type TreeNode struct {
	Id       string      `json:"id"`
	ParentId string      `json:"parentId"`
	Label    string      `json:"label"`
	Type     string      `json:"type"`
	Payload  interface{} `json:"payload"`
	Leaf     bool        `json:"leaf"`
	Children []TreeNode  `json:"children"`
}
